package cn.itcast.zuoyebang.fragment;


import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

public class FragmentAdapter extends FragmentPagerAdapter {

    private List<Fragment> mList = new ArrayList<>();

    public FragmentAdapter(@NonNull FragmentManager fm,List<Fragment> list) {
        super(fm);
        mList = list;//将fragment装入容器里
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return mList.get(position);//获取容器内的Fragment并返回
    }

    @Override
    public int getCount() {
        return mList == null ? 0 : mList.size();//判断容器是否为空，如果不为空则返回容器的数量（？）
    }
}
